library(tidyverse)
library(readxl)
path = "files/2025-05-11/Challenge 23.xlsx"
input = read_excel(path, range = "B2:D28")
test = read_excel(path, range = "F2:G6") %>%
rename("Quarter" = 1)
result = input %>%
mutate(Quarter = paste0("Q", quarter(Date))) %>%
summarise(
Production = sum(
`Production (L)`[`Temp (°C)` >= -10 & `Temp (°C)` <= -5],
na.rm = TRUE
),
.by = Quarter
)
all.equal(result, test)
#> [1] TRUECrispo - Excel Challenge 19 2025
excel-challenges
weekly-exercises
Easy Sunday Excel Challenge

Challenge Description
Easy Sunday Excel Challenge
⭐ ⭐Sum Production per Quarter
Solutions
Logic:
Reads the workbook range needed for the challenge
Aggregates or ranks values at the correct grouping level
Builds the intermediate helper columns that drive the final answer
Strengths:
- The R solution stays compact and mirrors the workbook logic closely.
Areas for Improvement:
- The code assumes the workbook layout and named ranges remain stable.
Gem:
- The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd
path = "Challenge 23.xlsx"
input_data = pd.read_excel(path, usecols="B:D", skiprows=1, nrows=27)
test = pd.read_excel(path, usecols="F:G", skiprows=1, nrows=5)
test.columns = ["Quarter", "Production"]
input_data["Date"] = pd.to_datetime(input_data["Date"])
input_data["Quarter"] = "Q" + input_data["Date"].dt.quarter.astype(str)
result = (
input_data.loc[input_data["Temp (°C)"].between(-10, -5)]
.groupby("Quarter", as_index=False)["Production (L)"]
.sum()
.rename(columns={"Production (L)": "Production"})
)
print(result.equals(test))Logic:
Reads the workbook range needed for the challenge
Aggregates or ranks values at the correct grouping level
Strengths:
- The Python version keeps the same rule in a direct pandas-oriented workflow.
Areas for Improvement:
- As with the R version, any workbook layout change would require small adjustments.
Gem:
- The implementation stays close to the stated challenge instead of adding unnecessary complexity.
Difficulty Level
This task is easy to moderate:
- The business rule is readable, but the workbook still needs a few careful transformation steps.